home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / spoc88 / cengn / engine.c < prev    next >
Text File  |  1988-06-22  |  2KB  |  50 lines

  1. /************************************************************
  2.  ENGINE.C - by Jake Richter
  3.  
  4.     Provides core routine for a search engine that searches
  5. the current directory for a given file name (which may
  6. contain wildcards) with specific attributes. When a file is
  7. found, the engine calls a function whose pointer it is
  8. passed upon entry with the contents of the DTA returned by
  9. the Find First and Find Next functions.
  10. ************************************************************/ 
  11. #include "dos.h"         /* Contains ffblk structure.      */
  12. #include "dir.h"         /* Required by findfirst, findnext,
  13.                             getcwd.                        */ 
  14.  
  15. /************************************************************
  16.                     Program Definitions
  17. ************************************************************/
  18. #define FALSE       0
  19. #define TRUE        !FALSE
  20. typedef struct ffblk FFBLK;
  21.  
  22. /************************************************************
  23.                  Mandatory Global Declarations
  24. ************************************************************/
  25. static  FFBLK   procBlock;       /* Declare a file info block 
  26.                                     for the specific procs.*/
  27.  
  28. /************************************************************
  29.   void SearchEngine(filename, attribute, procPtr)
  30.  
  31.     This routine sets up the call for the recursive tree
  32. search routine and the search engine.
  33. ************************************************************/
  34. void SearchEngine(filename, attribute, procPtr)
  35. char  *filename;
  36. char  attribute;
  37. void  (*procPtr)();
  38. {
  39.   int     done;
  40.  
  41.   done = findfirst(filename, &procBlock, attribute);
  42.                /* While there are still matching files...  */
  43.   while (!done)
  44.     {
  45.     (*procPtr)(&procBlock); /* Call the user's function.   */
  46.     done = findnext(&procBlock); /* Search again.          */
  47.     }
  48.   return;
  49. }
  50.